const seatingModel = require("../models/seatingModel");

module.exports = {
    //查询
    async Allseating() {
        return await seatingModel.find().exec()
    },
    //创建选座位置
    async seatingData({scheduleId,seatId}) {
        return await seatingModel.create({
            scheduleId,seatId
        })
    },
     //查找所有的选座详细信息
     async showSeatingData(seatingId) {
        return await seatingModel.findById(seatingId).exec()
    },
     //查找行列
     async queryToRepeats({scheduleId,seatId}) {
        return await seatingModel.findOne({scheduleId,seatId}).exec()
    },
     //删除选座
     async deleteSeating(seatingid) {
        return await seatingModel.deleteOne({
            '_id':seatingid
        }).exec()
    },
    //修改选座
    async modifySeating({'_id':seatingId},{scheduleId,seatId}) {
        return await seatingModel.updateOne({"_id":seatingId}, {scheduleId,seatId}).exec()
    },
    //分页
    // currentPage:当页页数
    // pageSize： 每页显示的条数 
    async accessToPag({
        currentpage,
        pagesize
    }) {
        return await seatingModel.find()
            .skip((currentpage - 1) * pagesize)
            .limit(pagesize)
            .sort({
                '_id': -1
            })
            .exec()
    },
    //数据的总条数
    async getsNumber() {
        return seatingModel.countDocuments().exec()
    },
}